<template>
  <div :class="['right-box', isHidden ? 'hidden-icon' : '']">
    <div class="fold-icon" @click="closeRightBox">
      <el-icon>
        <DArrowRight :class="{ 'hidden-icon': isHidden }" />
      </el-icon>
    </div>
    <div class="box-first">
      <div class="right-title">
        <img src="@/assets/images/home/pic_img.png" />
        <span>覆盖范围</span>
      </div>
      <div class="box-all">
        <div class="item-one" :key="index" v-for="(item, index) in state.placeArr">
          <div class="one-left">
            <!-- <img :src="`./src/assets/images/home/${item.img}`" /> -->
            <img :src="getIconAssetURL(item.img)" />
          </div>
          <div class="one-right">
            <div class="number">
              <span>{{ item.number }}</span>
              <span>{{ item.unit }}</span>
            </div>
            <div class="word">
              {{ item.name }}
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="box-second">
      <div class="right-title">
        <img src="@/assets/images/home/pic_img.png" />
        <span>对外服务访问概览</span>
      </div>
      <div class="echart-header">
        <div class="header-left">
          <span>服务接口</span>
          <span>65</span>
        </div>
        <div class="header-right">
          <span>近30日调用次数</span>
          <span>2,300</span>
        </div>
      </div>
      <div class="echart-main">
        <line-chart
          :height="'130px'"
          :x-labels="[
            '5/1',
            '5/6',
            '5/8',
            '5/10',
            '5/12',
            '5/14',
            '5/15',
            '5/16',
            '5/18',
            '5/26',
            '5/28',
            '5/30'
          ]"
          :y-values="[20, 12, 91, 24, 20, 30, 10, 20, 54, 90, 30, 41]"
        />
      </div>
    </div>
    <div class="box-three">
      <div class="right-title">
        <img src="@/assets/images/home/pic_img.png" />
        <span>模型运行概览</span>
      </div>
      <div class="table-box">
        <div class="table-header">
          <div class="table-name">模型名称</div>
          <div class="table-type">模型类型</div>
          <div class="table-ip">IP</div>
          <div class="table-run">运行情况</div>
        </div>

        <div class="table-content">
          <vue3-seamless-scroll :list="tableData" :hover="true" :step="0.2" class="indexscroll">
            <div :key="index" v-for="(item, index) in tableData" class="table-obj">
              <div class="table-name">{{ item.name }}</div>
              <div class="table-type">{{ item.type }}</div>
              <div class="table-ip">{{ item.ip }}</div>
              <div class="table-run">
                <img src="@/assets/images/home/u89.svg" />
              </div>
            </div>
          </vue3-seamless-scroll>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref, reactive, watch } from 'vue'
import LineChart from '@/components/app-echart/service-visit-chart.vue'
import yshplaceArr from '@/assets/data/map_data/yshInfo/yshreset.json'
import dwhplaceArr from '@/assets/data/map_data/reset.json'
import { Vue3SeamlessScroll } from 'vue3-seamless-scroll'
// import { place, table_data } from '../../data'
import { getIconAssetURL } from '@/utils/loadAssets'

const props = defineProps({
  riverValue: {
    type: String,
    default: '1'
  }
})
const state = reactive({
  placeArr: []
})
watch(
  () => props.riverValue,
  () => {
    if (props.riverValue == 1) {
      console.log(dwhplaceArr, state)
      state.placeArr = dwhplaceArr
    } else if (props.riverValue == 2) {
      state.placeArr = yshplaceArr
    }
  },
  { immediate: true, deep: true }
)

const tableData = reactive([
  {
    name: '新安江',
    type: '水文',
    ip: '10.37.3.152',
    status: '成功'
  },
  {
    name: '新安江',
    type: '水文',
    ip: '10.37.3.152',
    status: '成功'
  },
  {
    name: '新安江',
    type: '水文',
    ip: '10.37.3.152',
    status: '成功'
  },
  {
    name: '时空变源',
    type: '水文',
    ip: '10.37.3.153',
    status: '成功'
  },
  {
    name: '时空变源',
    type: '水文',
    ip: '10.37.3.153',
    status: '成功'
  }
])
const isHidden = ref(false)
const closeRightBox = () => {
  isHidden.value = !isHidden.value
}
</script>
<style lang="less" scoped>
.right-box {
  z-index: 101;
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 100%;
  background-image: url(@/assets/images/left_img.png);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  border-radius: 4px !important;
  border: 1px solid #1c629e;
  background-color: rgba(0, 1, 125, 0) !important;
  transition: right 1s;
  &.hidden-icon {
    right: -300px;
    transition: right 1s;
  }
  .fold-icon {
    width: 20px;
    height: 120px;
    line-height: 120px;
    position: absolute;
    background: #058cc7;
    top: 35%;
    left: -20px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top-left-radius: 35px;
    border-bottom-left-radius: 35px;
    transform: translateY(-50%);

    @keyframes myload {
      from {
        opacity: 0;
        -webkit-transform: rotate(0deg);
        /* Safari */
        transform: rotate(0deg);
        /* 标准语法 */
      }

      to {
        opacity: 1;
        -webkit-transform: rotate(0deg);
        /* Safari */
        transform: rotate(0deg);
        /* 标准语法 */
      }
    }

    .el-icon {
      cursor: pointer;
      position: relative;
      display: block;
      color: white;
      animation: myload 1s infinite ease-in-out;
      -webkit-animation: myload 1s infinite ease-in-out;

      svg {
        &.hidden-icon {
          // border-top-right-radius: 35px;
          // border-bottom-right-radius: 35px;
          transform: rotate(180deg);
        }
      }
    }
  }
  .box-first {
    height: 28%;
    .right-title {
      height: 35px;
      margin: 10px 0 15px 10px;
      display: flex;
      align-items: center;
      img {
        width: 30px;
        height: 30px;
        margin-right: 15px;
      }
      span {
        font-size: var(--header-fontsize);
        color: #ffffff;
      }
    }
    .box-all {
      height: calc(100% - 35px);
      display: flex;
      flex-wrap: wrap;
      margin-left: 20px;
      width: 100%;
      .item-one {
        display: flex;
        width: 44%;
        .one-left {
          img {
            width: 30px;
            height: 30px;
            margin: 10px 15px 0 0;
          }
        }
        .one-right {
          .number {
            span:nth-of-type(1) {
              font-family: 'Arial Negreta', 'Arial Normal', 'Arial', sans-serif;
              font-weight: 700;
              font-size: var(--content-fontsize);
              color: #b5d7ff;
            }
            span:nth-of-type(2) {
              color: #b5d7ff;
            }
          }
          .word {
            border-width: 0px;
            white-space: nowrap;
            text-transform: none;
            color: white;
            margin-top: 5px;
          }
        }
      }
    }
  }
  .box-second {
    height: 33%;
    .right-title {
      height: 35px;
      margin: 10px 0 15px 10px;
      display: flex;
      align-items: center;
      img {
        width: 30px;
        height: 30px;
        margin-right: 15px;
      }
      span {
        font-size: var(--content-fontsize);
        color: #ffffff;
      }
    }
    .echart-header {
      display: flex;
      justify-content: space-around;
      .header-left {
        border-radius: 8px;
        border: 2px solid rgba(0, 213, 255, 0.5);
        box-sizing: border-box;
        width: 120px;
        height: 43px;
        display: flex;
        justify-content: center;
        align-items: center;
        span:nth-of-type(1) {
          font-size: var(--content-fontsize);
          color: #9fe8ff;
          margin-right: 5px;
        }
        span:nth-of-type(2) {
          font-size: var(--content-fontsize);
          color: white;
        }
      }
      .header-right {
        border-radius: 8px;
        border: 2px solid rgba(0, 213, 255, 0.5);
        box-sizing: border-box;
        width: 140px;
        height: 43px;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        span:nth-of-type(1) {
          font-size: var(--content-fontsize);
          color: #9fe8ff;
          margin-right: 5px;
        }
        span:nth-of-type(2) {
          font-size: var(--content-fontsize);
          color: white;
        }
      }
    }
    .echart-main {
      margin-top: 10px;
    }
  }
  .box-three {
    height: 30%;
    .right-title {
      height: 35px;
      margin: 10px 0 15px 10px;
      display: flex;
      align-items: center;
      img {
        width: 30px;
        height: 30px;
        margin-right: 15px;
      }
      span {
        font-size: 18px;
        color: #ffffff;
      }
    }
    .table-box {
      height: calc(100% - 35px);
      .table-header {
        display: flex;
        justify-content: space-around;
        height: 36px;
        background-color: rgba(29, 126, 231, 0.4);
        font-size: 14px;
        font-weight: 700;
        line-height: 36px;
        box-sizing: border-box;
        padding-right: 6px;
        border: 1px solid #00d5ff;
        color: #00d5ff;
      }
      .table-content {
        height: calc(100% - 36px);
        .indexscroll {
          height: 100%;
          width: 100%;
          overflow: hidden;
          .table-obj:nth-of-type(odd) {
            width: 100%;
            display: flex;
            justify-content: space-around;
            height: 24px;
            box-sizing: border-box;
            font-size: 12px;
            line-height: 24px;
            color: #50a5ff;
            cursor: pointer;
            .table-name {
              width: 25%;
              text-align: center;
            }
            .table-type {
              width: 25%;
              text-align: center;
            }
            .table-ip {
              width: 25%;
              text-align: center;
            }
            .table-run {
              width: 25%;
              text-align: center;
            }
          }
          .table-obj:nth-of-type(even) {
            width: 100%;
            display: flex;
            justify-content: space-around;
            height: 24px;
            box-sizing: border-box;
            font-size: 12px;
            line-height: 24px;
            color: #50a5ff;
            cursor: pointer;
            background-color: rgba(29, 126, 231, 0.2);
            .table-name {
              width: 25%;
              text-align: center;
            }
            .table-type {
              width: 25%;
              text-align: center;
            }
            .table-ip {
              width: 25%;
              text-align: center;
            }
            .table-run {
              width: 25%;
              text-align: center;
            }
          }
        }
      }
    }
  }
}
</style>
